package net.hvacapp.cmvrfforandroid.ui.project.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import net.hvacapp.cmvrfforandroid.R;

/**
 * Created by zhangnorman on 15/7/31.
 */
public class DeviceItemView extends LinearLayout{

    private TextView mDeviceNameTv;
    private TextView mDeviceCountTv;
    private TextView mMinusTv;
    private TextView mAddTv;
    private TextView mDeleteTv;
    private int count;

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
        mDeviceCountTv.setText(count+"台");
    }

    public void setCount(int count, String uint) {
        this.count = count;
        mDeviceCountTv.setText(count+uint);
    }


    public DeviceItemView(Context context) {
        super(context);
        init(context, 0);
    }

    public DeviceItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, 0);
    }

    public DeviceItemView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context, defStyle);
    }

    public void setOnDeleteClickListener(View.OnClickListener onClickListener) {
        mDeleteTv.setOnClickListener(onClickListener);
    }

    public void setOnMinusClickListener(View.OnClickListener onClickListener) {
        mMinusTv.setOnClickListener(onClickListener);
    }

    public void setOnAddClickListener(View.OnClickListener onClickListener) {
        mAddTv.setOnClickListener(onClickListener);
    }

    public void deleteBtnDismiss() {
        mDeleteTv.setText("");
    }

    public void setDeviceString (String title) {
        mDeviceNameTv.setText(title);
    }

    private void init(Context context, int defStyle) {
        LayoutInflater.from(context).inflate(R.layout.view_device_item, this,
                true);
        mDeviceNameTv = (TextView) findViewById(R.id.tv_device_name);
        mDeviceCountTv = (TextView) findViewById(R.id.tv_device_count);
        mMinusTv = (TextView) findViewById(R.id.tv_minus);
        mAddTv = (TextView) findViewById(R.id.tv_add);
        mDeleteTv = (TextView) findViewById(R.id.tv_delete);

    }
}
